-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] Fix RightToLeft flow direction for FormattedText #31498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where FormattedText alignment was not considering flow direction on iOS/macOS platforms. The fix ensures that when using RTL flow direction with FormattedText, the text alignment properly adjusts to match the layout direction.
- Adds flow direction awareness to FormattedStringExtensions.ToNSAttributedString method
- Maintains backward compatibility by keeping existing public method signatures
- Includes comprehensive test coverage with both device tests and UI tests
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Core/tests/DeviceTests/Stubs/LabelStub.cs | Adds FormattedText property to test stub for testing FormattedString scenarios |
| src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.iOS.cs | Adds device test to verify FormattedText alignment with different flow directions |
| src/Core/src/Platform/iOS/FlowDirectionExtensions.cs | Adds internal method to convert FlowDirection to UIUserInterfaceLayoutDirection |
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31480.cs | Adds UI test to verify FormattedText flow direction behavior through screenshots |
| src/Controls/tests/TestCases.HostApp/Issues/Issue31480.cs | Adds test page with various FormattedText alignment scenarios for manual and automated testing |
| src/Controls/src/Core/Platform/iOS/Extensions/FormattedStringExtensions.cs | Core fix that makes FormattedText alignment respect flow direction by checking parent Label's FlowDirection |
Description of Change
In
FormattedStringExtensions.ToNSAttributedString, the paragraph style alignment is not considering flow direction.The PR apply changes to the
ToNSAttributedStringmethod and because the changes apply to .NET 9, maintains backward compatibility by keeping existing public method signatures.Before

After

Added Device Tests and UITest to verify all alignment combinations for FormattedText with both LTR and RTL flow directions.
Issues Fixed
Fixes #31480